package com.testng.oa.pub;
import java.util.Set;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class oaindex {
	private static WebElement element = null;
	public static String okstyle = "background-image: url(\"mode/icons/ok.png\");";
	
	public static WebElement getoldpassword(WebDriver driver){
		element = driver.findElement(By.name("passoldPost"));
		return element;
	}
	
	public static WebElement getpostpassword(WebDriver driver){
		element = driver.findElement(By.name("passwordPost"));
		return element;
	}
	
	public static WebElement getpostpasswordconfirm(WebDriver driver){
		element = driver.findElement(By.name("password1Post"));
		return element;
	}
	
	public static WebElement getchangepassbtn(WebDriver driver){
		element = driver.findElement(By.xpath("//div[2]/div/div/div/span/div/div/div[2]/div/div/a/span/span/span"));
		return element;
	}
	
	public static WebElement getchangepasswrongstr(WebDriver driver){
		element = driver.findElement(By.xpath("/html/body/div[4]/div[2]/div[2]/div/div/div/span/div/div/div[2]/div/div/div/span"));
		return element;
	}
	
	public static WebElement getadditembtn(WebDriver driver){
		element = driver.findElement(By.xpath("//div[2]/div/div/div[2]/div/div/a/span/span/span"));
		return element;
	}
	
	public static WebElement getsaveitembtn(WebDriver driver){
		element = driver.findElement(By.xpath("//div[2]/div/div/div[2]/div/div/a[2]/span/span/span"));
		return element;
	}
	
	public static WebElement getkaoqinmenu(WebDriver driver){
		element = driver.findElement(By.xpath("//span[contains(.,'在线考勤')]"));
		return element;
	}
	
	public static WebElement getkaoqinitemwind(WebDriver driver){
		element = driver.findElement(By.xpath("//div[7]/div/div/div/div/div/span"));
		return element;
	}
	
	public static WebElement getkaoqinitemwindclose(WebDriver driver){
		element = driver.findElement(By.xpath("//div[7]/div/div/div/div/div[4]/img"));
		return element;
	}
	
	public static WebElement getaddricheng(WebDriver driver){
		element = driver.findElement(By.linkText("新增日程"));
		return element;
	}
	
	public static WebElement getaddrichengtitle(WebDriver driver){
		element = driver.findElement(By.name("titlePost"));
		return element;
	}
	
	public static WebElement getaddrichengsavebtn(WebDriver driver){
		element = driver.findElement(By.xpath("//div[2]/div/div[2]/div/div/a/span/span/span"));
		return element;
	}
	
	public static WebElement getaddrichengguanli(WebDriver driver){
		element = driver.findElement(By.linkText("日程管理"));
		return element;
	}
	
	public static WebElement getlink(WebDriver driver, String linkText){
		element = driver.findElement(By.linkText(linkText));
		return element;
	}
	
	public static WebElement getelementbyid(WebDriver driver, String id){
		element = driver.findElement(By.id(id));
		return element;
	}
	
	public static WebElement getelementbyxpath(WebDriver driver, String xpath){
		element = driver.findElement(By.xpath(xpath));
		return element;
	}
	
	public static WebElement getpartiallink(WebDriver driver, String linkText){
		element = driver.findElement(By.partialLinkText(linkText));
		return element;
	}

	public static WebElement getjingdianstylemenu(WebDriver driver) {
		element = driver.findElement(By.id("menuitem-1129-itemEl"));
		return element;
	}
	
	public static WebElement getjingdianstyleok(WebDriver driver) {
		element = driver.findElement(By.id("menuitem-1129-iconEl"));
		return element;
	}
	
	public static WebElement getlansestylemenu(WebDriver driver) {
		element = driver.findElement(By.id("menuitem-1130-itemEl"));
		return element;
	}
	
	public static WebElement getlansestyleok(WebDriver driver) {
		element = driver.findElement(By.id("menuitem-1130-iconEl"));
		return element;
	}
	
	public static WebElement getmobilebtn(WebDriver driver) {
		element = driver.findElement(By.id("button-1048"));
		return element;
	}
	
	public static WebElement getmobiletitle(WebDriver driver) {
		element = driver.findElement(By.id("loginmobile_title"));
		return element;
	}
	
	public static WebElement getmobilecancel(WebDriver driver) {
		element = driver.findElement(By.id("loginmobile_cancel"));
		return element;
	}
	
	public static WebElement getexpandimg(WebDriver driver) {
		element = driver.findElement(By.id("tool-1057-toolEl"));
		return element;
	}

	public static WebElement getchatbtn(WebDriver driver) {
		element = driver.findElement(By.id("button-1050"));
		return element;
	}
	
	public static WebElement getreloadbtn(WebDriver driver) {
		element = driver.findElement(By.id("button-1052"));
		return element;
	}
	
	public static WebElement getmaxbtn(WebDriver driver) {
		element = driver.findElement(By.id("button-1054"));
		return element;
	}

	public static WebElement getcentertable1(WebDriver driver) {
		element = driver.findElement(By.xpath("/html/body/div[4]/div/div/div[2]/div/a/span/span/span"));
		return element;
	}
	
	public static WebElement getcentertable2(WebDriver driver) {
		element = driver.findElement(By.xpath("/html/body/div[4]/div/div/div[2]/div/a[2]/span/span/span"));
		return element;
	}
	
	public static WebElement getcentertable3(WebDriver driver) {
		element = driver.findElement(By.xpath("/html/body/div[4]/div/div/div[2]/div/a[3]/span/span/span"));
		return element;
	}
	
	public static String openLink(WebDriver driver, String linkText, String handle){
		String url = "";
		getlink(driver, linkText).click();
		Set<String> handles = driver.getWindowHandles();
		for (String handle1 : handles) {
			if (handle.equals(handle1) == false) {
				driver.switchTo().window(handle1);
				url=driver.getCurrentUrl();
				driver.close();
				driver.switchTo().window(handle);
			}
		}
		return url;
	}
	
	public static String openchat(WebDriver driver, String handle){
		String url = "";
		getchatbtn(driver).click();
		Set<String> handles = driver.getWindowHandles();
		for (String handle1 : handles) {
			if (handle.equals(handle1) == false) {
				driver.switchTo().window(handle1);
				url=driver.getCurrentUrl();
				driver.close();
				driver.switchTo().window(handle);
			}
		}
		return url;
	}
}
